#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ioctl.h>

#include "screen.h"
#include "log.h"

void clear_screen(void)
{
	printf("\033[2J\033[0;0H");
}

int get_screen_cols(void)
{
	struct winsize ws;

	ioctl(1, TIOCGWINSZ, &ws);

	return ws.ws_col == 0 ? 0 : ws.ws_col;
}

int get_screen_rows(void)
{
	struct winsize ws;

	ioctl(1, TIOCGWINSZ, &ws);

	return ws.ws_row == 0 ? 0 : ws.ws_row;
}
